package com.tensquare.zuul.controller;

import com.google.common.collect.Maps;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 网关映射异常视图解析器
 */
@Component
public class TensquareErrorViewResolver implements ErrorViewResolver {

    /**
     * 重定向到   我们的错误页面
     * @param request
     * @param status
     * @param model
     * @return
     */
    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
        return new ModelAndView("redirect:/gatewayerror", Maps.newHashMap());
    }
}
